﻿using System;
using UnityEngine;

namespace RootMotion
{
	// Token: 0x020001D0 RID: 464
	public static class BipedNaming
	{
		// Token: 0x06000982 RID: 2434 RVA: 0x000336EC File Offset: 0x00031AEC
		public static Transform[] GetBonesOfType(BipedNaming.BoneType boneType, Transform[] bones)
		{
			Transform[] array = new Transform[0];
			foreach (Transform transform in bones)
			{
				if (transform != null && BipedNaming.GetBoneType(transform.name) == boneType)
				{
					Array.Resize<Transform>(ref array, array.Length + 1);
					array[array.Length - 1] = transform;
				}
			}
			return array;
		}

		// Token: 0x06000983 RID: 2435 RVA: 0x0003374C File Offset: 0x00031B4C
		public static Transform[] GetBonesOfSide(BipedNaming.BoneSide boneSide, Transform[] bones)
		{
			Transform[] array = new Transform[0];
			foreach (Transform transform in bones)
			{
				if (transform != null && BipedNaming.GetBoneSide(transform.name) == boneSide)
				{
					Array.Resize<Transform>(ref array, array.Length + 1);
					array[array.Length - 1] = transform;
				}
			}
			return array;
		}

		// Token: 0x06000984 RID: 2436 RVA: 0x000337AC File Offset: 0x00031BAC
		public static Transform[] GetBonesOfTypeAndSide(BipedNaming.BoneType boneType, BipedNaming.BoneSide boneSide, Transform[] bones)
		{
			Transform[] bonesOfType = BipedNaming.GetBonesOfType(boneType, bones);
			return BipedNaming.GetBonesOfSide(boneSide, bonesOfType);
		}

		// Token: 0x06000985 RID: 2437 RVA: 0x000337C8 File Offset: 0x00031BC8
		public static Transform GetFirstBoneOfTypeAndSide(BipedNaming.BoneType boneType, BipedNaming.BoneSide boneSide, Transform[] bones)
		{
			Transform[] bonesOfTypeAndSide = BipedNaming.GetBonesOfTypeAndSide(boneType, boneSide, bones);
			if (bonesOfTypeAndSide.Length == 0)
			{
				return null;
			}
			return bonesOfTypeAndSide[0];
		}

		// Token: 0x06000986 RID: 2438 RVA: 0x000337EC File Offset: 0x00031BEC
		public static Transform GetNamingMatch(Transform[] transforms, params string[][] namings)
		{
			foreach (Transform transform in transforms)
			{
				bool flag = true;
				foreach (string[] namingConvention in namings)
				{
					if (!BipedNaming.matchesNaming(transform.name, namingConvention))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					return transform;
				}
			}
			return null;
		}

		// Token: 0x06000987 RID: 2439 RVA: 0x0003385C File Offset: 0x00031C5C
		public static BipedNaming.BoneType GetBoneType(string boneName)
		{
			if (BipedNaming.isSpine(boneName))
			{
				return BipedNaming.BoneType.Spine;
			}
			if (BipedNaming.isHead(boneName))
			{
				return BipedNaming.BoneType.Head;
			}
			if (BipedNaming.isArm(boneName))
			{
				return BipedNaming.BoneType.Arm;
			}
			if (BipedNaming.isLeg(boneName))
			{
				return BipedNaming.BoneType.Leg;
			}
			if (BipedNaming.isTail(boneName))
			{
				return BipedNaming.BoneType.Tail;
			}
			if (BipedNaming.isEye(boneName))
			{
				return BipedNaming.BoneType.Eye;
			}
			return BipedNaming.BoneType.Unassigned;
		}

		// Token: 0x06000988 RID: 2440 RVA: 0x000338B8 File Offset: 0x00031CB8
		public static BipedNaming.BoneSide GetBoneSide(string boneName)
		{
			if (BipedNaming.isLeft(boneName))
			{
				return BipedNaming.BoneSide.Left;
			}
			if (BipedNaming.isRight(boneName))
			{
				return BipedNaming.BoneSide.Right;
			}
			return BipedNaming.BoneSide.Center;
		}

		// Token: 0x06000989 RID: 2441 RVA: 0x000338D8 File Offset: 0x00031CD8
		public static Transform GetBone(Transform[] transforms, BipedNaming.BoneType boneType, BipedNaming.BoneSide boneSide = BipedNaming.BoneSide.Center, params string[][] namings)
		{
			Transform[] bonesOfTypeAndSide = BipedNaming.GetBonesOfTypeAndSide(boneType, boneSide, transforms);
			return BipedNaming.GetNamingMatch(bonesOfTypeAndSide, namings);
		}

		// Token: 0x0600098A RID: 2442 RVA: 0x000338F5 File Offset: 0x00031CF5
		private static bool isLeft(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeLeft) || BipedNaming.lastLetter(boneName) == "L" || BipedNaming.firstLetter(boneName) == "L";
		}

		// Token: 0x0600098B RID: 2443 RVA: 0x0003392F File Offset: 0x00031D2F
		private static bool isRight(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeRight) || BipedNaming.lastLetter(boneName) == "R" || BipedNaming.firstLetter(boneName) == "R";
		}

		// Token: 0x0600098C RID: 2444 RVA: 0x00033969 File Offset: 0x00031D69
		private static bool isSpine(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeSpine) && !BipedNaming.excludesNaming(boneName, BipedNaming.typeExcludeSpine);
		}

		// Token: 0x0600098D RID: 2445 RVA: 0x0003398C File Offset: 0x00031D8C
		private static bool isHead(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeHead) && !BipedNaming.excludesNaming(boneName, BipedNaming.typeExcludeHead);
		}

		// Token: 0x0600098E RID: 2446 RVA: 0x000339AF File Offset: 0x00031DAF
		private static bool isArm(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeArm) && !BipedNaming.excludesNaming(boneName, BipedNaming.typeExcludeArm);
		}

		// Token: 0x0600098F RID: 2447 RVA: 0x000339D2 File Offset: 0x00031DD2
		private static bool isLeg(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeLeg) && !BipedNaming.excludesNaming(boneName, BipedNaming.typeExcludeLeg);
		}

		// Token: 0x06000990 RID: 2448 RVA: 0x000339F5 File Offset: 0x00031DF5
		private static bool isTail(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeTail) && !BipedNaming.excludesNaming(boneName, BipedNaming.typeExcludeTail);
		}

		// Token: 0x06000991 RID: 2449 RVA: 0x00033A18 File Offset: 0x00031E18
		private static bool isEye(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeEye) && !BipedNaming.excludesNaming(boneName, BipedNaming.typeExcludeEye);
		}

		// Token: 0x06000992 RID: 2450 RVA: 0x00033A3B File Offset: 0x00031E3B
		private static bool isTypeExclude(string boneName)
		{
			return BipedNaming.matchesNaming(boneName, BipedNaming.typeExclude);
		}

		// Token: 0x06000993 RID: 2451 RVA: 0x00033A48 File Offset: 0x00031E48
		private static bool matchesNaming(string boneName, string[] namingConvention)
		{
			if (BipedNaming.excludesNaming(boneName, BipedNaming.typeExclude))
			{
				return false;
			}
			foreach (string value in namingConvention)
			{
				if (boneName.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06000994 RID: 2452 RVA: 0x00033A90 File Offset: 0x00031E90
		private static bool excludesNaming(string boneName, string[] namingConvention)
		{
			foreach (string value in namingConvention)
			{
				if (boneName.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06000995 RID: 2453 RVA: 0x00033AC8 File Offset: 0x00031EC8
		private static bool matchesLastLetter(string boneName, string[] namingConvention)
		{
			foreach (string letter in namingConvention)
			{
				if (BipedNaming.LastLetterIs(boneName, letter))
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06000996 RID: 2454 RVA: 0x00033B00 File Offset: 0x00031F00
		private static bool LastLetterIs(string boneName, string letter)
		{
			string a = boneName.Substring(boneName.Length - 1, 1);
			return a == letter;
		}

		// Token: 0x06000997 RID: 2455 RVA: 0x00033B24 File Offset: 0x00031F24
		private static string firstLetter(string boneName)
		{
			if (boneName.Length > 0)
			{
				return boneName.Substring(0, 1);
			}
			return string.Empty;
		}

		// Token: 0x06000998 RID: 2456 RVA: 0x00033B40 File Offset: 0x00031F40
		private static string lastLetter(string boneName)
		{
			if (boneName.Length > 0)
			{
				return boneName.Substring(boneName.Length - 1, 1);
			}
			return string.Empty;
		}

		// Token: 0x04000647 RID: 1607
		public static string[] typeLeft = new string[]
		{
			" L ",
			"_L_",
			"-L-",
			" l ",
			"_l_",
			"-l-",
			"Left",
			"left",
			"CATRigL"
		};

		// Token: 0x04000648 RID: 1608
		public static string[] typeRight = new string[]
		{
			" R ",
			"_R_",
			"-R-",
			" r ",
			"_r_",
			"-r-",
			"Right",
			"right",
			"CATRigR"
		};

		// Token: 0x04000649 RID: 1609
		public static string[] typeSpine = new string[]
		{
			"Spine",
			"spine",
			"Pelvis",
			"pelvis",
			"Root",
			"root",
			"Torso",
			"torso",
			"Body",
			"body",
			"Hips",
			"hips",
			"Neck",
			"neck",
			"Chest",
			"chest"
		};

		// Token: 0x0400064A RID: 1610
		public static string[] typeHead = new string[]
		{
			"Head",
			"head"
		};

		// Token: 0x0400064B RID: 1611
		public static string[] typeArm = new string[]
		{
			"Arm",
			"arm",
			"Hand",
			"hand",
			"Wrist",
			"Wrist",
			"Elbow",
			"elbow",
			"Palm",
			"palm"
		};

		// Token: 0x0400064C RID: 1612
		public static string[] typeLeg = new string[]
		{
			"Leg",
			"leg",
			"Thigh",
			"thigh",
			"Calf",
			"calf",
			"Femur",
			"femur",
			"Knee",
			"knee",
			"Foot",
			"foot",
			"Ankle",
			"ankle",
			"Hip",
			"hip"
		};

		// Token: 0x0400064D RID: 1613
		public static string[] typeTail = new string[]
		{
			"Tail",
			"tail"
		};

		// Token: 0x0400064E RID: 1614
		public static string[] typeEye = new string[]
		{
			"Eye",
			"eye"
		};

		// Token: 0x0400064F RID: 1615
		public static string[] typeExclude = new string[]
		{
			"Nub",
			"Dummy",
			"dummy",
			"Tip",
			"IK",
			"Mesh"
		};

		// Token: 0x04000650 RID: 1616
		public static string[] typeExcludeSpine = new string[]
		{
			"Head",
			"head"
		};

		// Token: 0x04000651 RID: 1617
		public static string[] typeExcludeHead = new string[]
		{
			"Top",
			"End"
		};

		// Token: 0x04000652 RID: 1618
		public static string[] typeExcludeArm = new string[]
		{
			"Collar",
			"collar",
			"Clavicle",
			"clavicle",
			"Finger",
			"finger",
			"Index",
			"index",
			"Mid",
			"mid",
			"Pinky",
			"pinky",
			"Ring",
			"Thumb",
			"thumb",
			"Adjust",
			"adjust",
			"Twist",
			"twist"
		};

		// Token: 0x04000653 RID: 1619
		public static string[] typeExcludeLeg = new string[]
		{
			"Toe",
			"toe",
			"Platform",
			"Adjust",
			"adjust",
			"Twist",
			"twist"
		};

		// Token: 0x04000654 RID: 1620
		public static string[] typeExcludeTail = new string[0];

		// Token: 0x04000655 RID: 1621
		public static string[] typeExcludeEye = new string[]
		{
			"Lid",
			"lid",
			"Brow",
			"brow",
			"Lash",
			"lash"
		};

		// Token: 0x04000656 RID: 1622
		public static string[] pelvis = new string[]
		{
			"Pelvis",
			"pelvis",
			"Hip",
			"hip"
		};

		// Token: 0x04000657 RID: 1623
		public static string[] hand = new string[]
		{
			"Hand",
			"hand",
			"Wrist",
			"wrist",
			"Palm",
			"palm"
		};

		// Token: 0x04000658 RID: 1624
		public static string[] foot = new string[]
		{
			"Foot",
			"foot",
			"Ankle",
			"ankle"
		};

		// Token: 0x020001D1 RID: 465
		[Serializable]
		public enum BoneType
		{
			// Token: 0x0400065A RID: 1626
			Unassigned,
			// Token: 0x0400065B RID: 1627
			Spine,
			// Token: 0x0400065C RID: 1628
			Head,
			// Token: 0x0400065D RID: 1629
			Arm,
			// Token: 0x0400065E RID: 1630
			Leg,
			// Token: 0x0400065F RID: 1631
			Tail,
			// Token: 0x04000660 RID: 1632
			Eye
		}

		// Token: 0x020001D2 RID: 466
		[Serializable]
		public enum BoneSide
		{
			// Token: 0x04000662 RID: 1634
			Center,
			// Token: 0x04000663 RID: 1635
			Left,
			// Token: 0x04000664 RID: 1636
			Right
		}
	}
}
